﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Maticsoft.Common;
using LTP.Accounts.Bus;
namespace ZGEDrySaltery.Web.address
{
    public partial class Add : Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
                       
        }

        		protected void btnSave_Click(object sender, EventArgs e)
		{
			
			string strErr="";
			if(this.txtADDRESS.Text.Trim().Length==0)
			{
				strErr+="ADDRESS不能为空！\\n";	
			}
			if(this.txtCREATE_USER_ID.Text.Trim().Length==0)
			{
				strErr+="CREATE_USER_ID不能为空！\\n";	
			}
			if(this.txtCREATE_USER_NAME.Text.Trim().Length==0)
			{
				strErr+="CREATE_USER_NAME不能为空！\\n";	
			}
			if(!PageValidate.IsDateTime(txtCREATE_TIME.Text))
			{
				strErr+="CREATE_TIME格式错误！\\n";	
			}
			if(!PageValidate.IsNumber(txtSORT_INDEX.Text))
			{
				strErr+="SORT_INDEX格式错误！\\n";	
			}
			if(this.txtSTATUS.Text.Trim().Length==0)
			{
				strErr+="STATUS不能为空！\\n";	
			}
			if(this.txtCOSTOMER.Text.Trim().Length==0)
			{
				strErr+="COSTOMER不能为空！\\n";	
			}
			if(this.txtTEL.Text.Trim().Length==0)
			{
				strErr+="TEL不能为空！\\n";	
			}
			if(this.txtREMARK.Text.Trim().Length==0)
			{
				strErr+="REMARK不能为空！\\n";	
			}
			if(this.txtSEX.Text.Trim().Length==0)
			{
				strErr+="SEX不能为空！\\n";	
			}

			if(strErr!="")
			{
				MessageBox.Show(this,strErr);
				return;
			}
			string ADDRESS=this.txtADDRESS.Text;
			string CREATE_USER_ID=this.txtCREATE_USER_ID.Text;
			string CREATE_USER_NAME=this.txtCREATE_USER_NAME.Text;
			DateTime CREATE_TIME=DateTime.Parse(this.txtCREATE_TIME.Text);
			int SORT_INDEX=int.Parse(this.txtSORT_INDEX.Text);
			string STATUS=this.txtSTATUS.Text;
			string COSTOMER=this.txtCOSTOMER.Text;
			string TEL=this.txtTEL.Text;
			string REMARK=this.txtREMARK.Text;
			string SEX=this.txtSEX.Text;

			ZGEDrySaltery.Model.address model=new ZGEDrySaltery.Model.address();
			model.ADDRESS=ADDRESS;
			model.CREATE_USER_ID=CREATE_USER_ID;
			model.CREATE_USER_NAME=CREATE_USER_NAME;
			model.CREATE_TIME=CREATE_TIME;
			model.SORT_INDEX=SORT_INDEX;
			model.STATUS=STATUS;
			model.COSTOMER=COSTOMER;
			model.TEL=TEL;
			model.REMARK=REMARK;
			model.SEX=SEX;

			ZGEDrySaltery.BLL.address bll=new ZGEDrySaltery.BLL.address();
			bll.Add(model);
			Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功！","add.aspx");

		}


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("list.aspx");
        }
    }
}
